package com.qdlc.p2p.dal.dao.impl;

import java.util.List;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import com.qdlc.p2p.dal.common.dao.jpa.BaseDaoImpl;
import com.qdlc.p2p.dal.dao.ExperienceBorrowDao;
import com.qdlc.p2p.dal.dto.ExperienceBorrow;

/**
 * 体验标（允许使用体验金投资的借款标）信息DAO接口
 * @author xxx
 * @version 2.0
 * @since 2015年04月23日 10时51分55秒
 */
@Repository(value = "experienceBorrowDao")
public class ExperienceBorrowDaoImpl extends BaseDaoImpl<ExperienceBorrow> implements ExperienceBorrowDao {

    @SuppressWarnings("unchecked")
    @Override
    public ExperienceBorrow getAdditionalExperienceBorrowById(long id) {
        String jpql = "from AdditionalExperienceBorrow where id = ?1";
        Query query = em.createQuery(jpql);
        query.setParameter(1, id);
        List<ExperienceBorrow> list = query.getResultList();
        if (list != null && list.size() >= 0) {
            return (ExperienceBorrow) list.get(0);
        } else {
            return null;
        }
    }
}
